package com.sskj.miner.presenter;

import android.view.View;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.miner.bean.MinerAssetBean;
import com.sskj.miner.bean.PaoBean;
import com.sskj.miner.bean.RuleBean;
import com.sskj.miner.http.HttpConfig;
import com.sskj.miner.ui.activity.MiningActivity;


public class MiningActivityPresenter extends BasePresenter<MiningActivity> {

    public void getAsset() {
        httpService.getAsset()
                .execute(new JsonCallBack<HttpData<MinerAssetBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<MinerAssetBean>> response) {
                        HttpData<MinerAssetBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updateUi(httpData.getData());
                        }
                    }
                });
    }

    public void getRule() {
        httpService.getRule()
                .execute(new JsonCallBack<HttpData<RuleBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<RuleBean>> response) {
                        HttpData<RuleBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.showNotice(httpData.getData().getContentCN());
                        }
                    }
                });
    }

    public void getPao() {
        httpService.getPao()
                .execute(new JsonCallBack<HttpData<PaoBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<PaoBean>> response) {
                        HttpData<PaoBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updatePao(httpData.getData());
                        }
                    }
                });
    }

    public void receivePao(String code, String num, String type, String largeType, View view) {
        httpService.receivePao(code, num, type, largeType)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.removeWaterView(view);
                        }
                    }
                });
    }
}
